Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

596
Visualizações
Mailu with docker on a Raspberry Pi running a "native" nginx web server

I configured Nextcloud on a Raspberry Pi 4 running Ubuntu Server 18.04.4 64-bit, following Carsten Rieger guide so now on the Pi is installed and running nginx. Then, using Mailu configuration I installed a mail server with Docker Compose. I chenged standard configuration because conflicting ports 80 and 443 used by "native" nginx and "docker container" nginx, so in container I use 8080 and 8443.

How must I configure native nginx so when I visit my mail.mydomain.com redirect to 8080 and 8443 ports? How can obtains certificates for HTTPS for mail.mydomain.com with Let's Encrypt?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

If I understand your problem correct, you like to use the nginx on the host as a proxy server to redirect traffic to the docker container.

Extend your nginx.conf on the host:

http {

...


  # redirect http to https from your domain
  server {
      listen 80;
      server_name localhost, <your domain>, <secondary domain>;
      return 301 https://<your domain>$request_uri;
  }

  # simple reverse-proxy
  server {
    listen 443;
    server_name  localhost, <your domain>, <secondary domain>;

    ssl on;
    # if you use let's encrypt (certbot) /etc/letsencrypt/live/<your domain>/fullchain.pem
    ssl_certificate      <path to certificate>;
    # if you use let's encrypt (certbot) /etc/letsencrypt/live/<your domain>/privkey.pem
    ssl_certificate_key  <path to key>;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # don’t use SSLv3 ref: POODLE

    client_max_body_size 200M;

    # pass requests for dynamic content to rails/turbogears/zope, et al
    location / {
      proxy_pass      http://localhost:8080;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_set_header Host $http_host;

      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forward-Proto http;
      proxy_set_header X-Nginx-Proxy true;

      proxy_redirect off;
    }
  }

... 

}

To Your second question, yes you can use Let's Encrypt to obtain the certificate. Either as standalone or with the nginx plugin.

$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install python-certbot-nginx

Obtain your certificate without nginx plugin (you need to stop the nginx first because certbot uses the port 80)

$ sudo certbot certonly --standalone -d <your domain> -d <secondary domain>

Obtain your certificate with the nginx plugin

$ sudo certbot --nginx -d <your domain> -d <secondary domain>

In any case you need to reload the nginx after a certificate was retrieved or renewed:

$ sudo service nginx reload 
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda